package cn.lanqiao.bigDate.mapper.data;

import cn.lanqiao.bigDate.entity.data.DataUser;
import cn.lanqiao.bigDate.entity.sys.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Mapper 接口
 * @author Marisa
 * @date 2022-03-29
 */
@Mapper
public interface DataUserMapper extends BaseMapper<DataUser> {

    @Select("<script>select t0.* from data_user t0 " +
                "where 1=1" +
                "<when test='id!=null and id!=&apos;&apos; '> and t0.id=#{id}</when> " +
                "<when test='loginAccount!=null and loginAccount!=&apos;&apos; '> and t0.login_account=#{loginAccount}</when> " +
                "<when test='userName!=null and userName!=&apos;&apos; '> and t0.user_name=#{userName}</when> " +
                "<when test='email!=null and email!=&apos;&apos; '> and t0.email=#{email}</when> " +
                "<when test='password!=null and password!=&apos;&apos; '> and t0.password=#{password}</when> " +
                "<when test='salt!=null and salt!=&apos;&apos; '> and t0.salt=#{salt}</when> " +
                "<when test='email!=null and email!=&apos;&apos; '> and t0.email=#{email}</when> " +
                "<when test='telephone!=null and telephone!=&apos;&apos; '> and t0.telephone=#{telephone}</when> " +
                "<when test='gender!=null and gender!=&apos;&apos; '> and t0.gender=#{gender}</when> " +
                "<when test='avatar!=null and avatar!=&apos;&apos; '> and t0.avatar=#{avatar}</when> " +
                "<when test='loginDate!=null and loginDate!=&apos;&apos; '> and t0.login_date=#{loginDate}</when> " +
                "<when test='createTime!=null and createTime!=&apos;&apos; '> and t0.create_time=#{createTime}</when> " +
                "<when test='updateTime!=null and updateTime!=&apos;&apos; '> and t0.update_time=#{updateTime}</when> " +
                //add here if need page limit
                //" limit ${page},${limit} " +
            " </script>")
    List<DataUser> pageAll(DataUser queryParamDTO, int page, int limit);

    @Select("<script>select count(1) from data_user t0 " +
                "where 1=1" +
                "<when test='id!=null and id!=&apos;&apos; '> and t0.id=#{id}</when> " +
                "<when test='loginAccount!=null and loginAccount!=&apos;&apos; '> and t0.login_account=#{loginAccount}</when> " +
                "<when test='userName!=null and userName!=&apos;&apos; '> and t0.user_name=#{userName}</when> " +
                "<when test='email!=null and email!=&apos;&apos; '> and t0.email=#{email}</when> " +
                "<when test='password!=null and password!=&apos;&apos; '> and t0.password=#{password}</when> " +
                "<when test='salt!=null and salt!=&apos;&apos; '> and t0.salt=#{salt}</when> " +
                "<when test='email!=null and email!=&apos;&apos; '> and t0.email=#{email}</when> " +
                "<when test='telephone!=null and telephone!=&apos;&apos; '> and t0.telephone=#{telephone}</when> " +
                "<when test='gender!=null and gender!=&apos;&apos; '> and t0.gender=#{gender}</when> " +
                "<when test='avatar!=null and avatar!=&apos;&apos; '> and t0.avatar=#{avatar}</when> " +
                "<when test='loginDate!=null and loginDate!=&apos;&apos; '> and t0.login_date=#{loginDate}</when> " +
                "<when test='createTime!=null and createTime!=&apos;&apos; '> and t0.create_time=#{createTime}</when> " +
                "<when test='updateTime!=null and updateTime!=&apos;&apos; '> and t0.update_time=#{updateTime}</when> " +
            " </script>")
    int countAll(DataUser queryParamDTO);
}
